package cn.tedu.hotel.controller;

import cn.tedu.hotel.pojo.vo.PriceListItemVO;
import cn.tedu.hotel.service.IPriceService;
import cn.tedu.hotel.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  处理房间价格相关的控制器
 */
@Api(tags = "07. 房间价格管理模块")
@Slf4j
@RestController
@RequestMapping("/prices")
public class PriceController {

    @Autowired
    IPriceService priceService;

    public PriceController(){
        log.debug("创建控制器：PriceController");
    }

    @ApiOperation("根据id删除房间价格")
    @ApiOperationSupport(order = 200)
    @PostMapping("/{id:[0-9]+}/delete")
    public JsonResult<Void> deleteById(@PathVariable Long id){
        log.debug("开始处理【删除房间价格】的请求，参数：id={}",id);
        priceService.deleteById(id);
        return JsonResult.ok();
    }


    @ApiOperation("查询房间价格列表")
    @ApiOperationSupport(order = 300)
    @GetMapping("")
    public JsonResult<List<PriceListItemVO>> listPrice(){
        log.debug("开始处理【查询房间价格列表】的请求");
        List<PriceListItemVO> priceListItemVOS = priceService.listPrice();
        return JsonResult.ok(priceListItemVOS);
    }


}

